﻿using System;

namespace Coogle.Core
{
    public class Container
    {
        private readonly ContainerCode m_code;
        private readonly ContainerType m_type;

        public ContainerCode Code
        {
            get { return m_code; }
        }

        public ContainerType Type
        {
            get { return m_type; }
        }

        public Container(String sign, int number, Int32 check, String type)
            : this(new ContainerCode(sign, number, check), new ContainerType(type))
        {
        }

        public Container(ContainerCode code, ContainerType type)
        {
            m_code = code;
            m_type = type;
        }

        public override Boolean Equals(object obj)
        {
            if (obj == null) return false;
            var cntr = obj as Container;
            if (cntr == null) return false;
            return (m_code.Equals(cntr.m_code) &&
                    m_type.Equals(cntr.m_type));
        }

        public override Int32 GetHashCode()
        {
            return m_code.GetHashCode() ^ m_type.GetHashCode();
        }
    }
}
